# @Version : 1.0
# @Author  : 刘宇
# @File    : 23_str_exercise.py
# @Time    : 2025/10/13 15:38

str_names="tom jack mary nono smith hsp"
# 将其分割成列表
str_names_list=str_names.split(" ")

print(f"一共有{len(str_names_list)}个人名")

str_names_new = str_names.replace("hsp", "老韩", 1)
print("str_names_new:", str_names_new)

str_names_upper=""
for element in str_names_list:
    if element.isalpha():
        str_names_upper += element.capitalize()+" "

        # 去掉两边的" "
str_name_upper=str_names_upper.strip(" ")
print(f"如果人名是英文，则把首字母改成大写 处理结果是:{str_names_upper}")
